<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .mask{
            display: none;
            /* fixed设置后，参照变成当前窗口 */
            position: fixed;
            height: 100%;
            width: 100%;
            background-color: rgba(0, 0, 0, .5);
        }
        .mask img{
            
            position: absolute;
            top: 50%;
            left: 50%;
            margin-top: -100px;
            margin-left: -100px;
            width: 200px;
            height: 200px;
            cursor: pointer;
        }
        .show{
            display: block;
        }
    </style>
</head>
<body>
    <div class="mask">
        <img src="0.jpg" alt="">
    </div>
    <button class="btn">报名</button>
    <script>
        var btn = document.querySelector('.btn');
        var mask = document.querySelector('.mask');

        btn.onclick = function () {
            mask.classList.add('show')
        }
        mask.onclick = function () {
            mask.classList.remove('show')
        }
    </script>
</body>
</html>